900A - Find Extra One - CodeForces Solution


geometry implementation *800

Please click on ads to support us..

Python Code:

n=int(input())
l=[]
g=0
h=0

for i in range (0 , n):
    l=[int(num) for num in input().split()]
    if l[0]>0:
        h=h+1
    else:
        g=g+1
        
if g==1 or h==1 or h==0 or g==0 :
    print("YES")
else:
    print('NO')
        
    
    

C++ Code:

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define elif else if
#define pow pwr
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const ll N=2e5+10;
const int mod = 1e9+7;
int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> points(n, vector<ll>(2, 0));
    for(ll i = 0; i < n; ++i){
        for(ll j = 0; j < 2; ++j){
            cin>>points[i][j];
        }
    }
    ll ct_pos = 0, ct_neg = 0;
    for(ll i = 0; i < n; ++i){
        if(points[i][0] > 0){
            ct_pos++;
        }else{
            ct_neg++;
        }
    }
    if(ct_pos > 0 && ct_neg > 0 && ct_pos != 1 && ct_neg != 1){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
    return 0;
}


Comments

Submit
1 Comments
  • 20/3/2024 11:23 - Asia/Tashkent

print(5)


More Questions

1000B - Light It Up
218B - Airport
1463B - Find The Array
1538C - Number of Pairs
621B - Wet Shark and Bishops
476B - Dreamoon and WiFi
152C - Pocket Book
1681D - Required Length
1725D - Deducing Sortability
1501A - Alexey and Train
721B - Passwords
1263D - Secret Passwords
1371B - Magical Calendar
1726E - Almost Perfect
1360C - Similar Pairs
900A - Find Extra One
1093D - Beautiful Graph
748A - Santa Claus and a Place in a Class
1511B - GCD Length
676B - Pyramid of Glasses
597A - Divisibility
1632A - ABC
1619D - New Year's Problem
242B - Big Segment
938A - Word Correction
159C - String Manipulation 10
258A - Little Elephant and Bits
1536C - Diluc and Kaeya
1428C - ABBB
1557A - Ezzat and Two Subsequences